Imports System.IO

Public Class Log

    Public Shared Sub LogData(ByVal data As String)
        Dim nightfile As String

        If Now.Hour > 8 Then
            nightfile = "wk"
        Else
            nightfile = "am"
        End If

        Dim outfile As String = "logfile_" & Now.Year & Now.Month.ToString("00") & Now.Day.ToString("00") & nightfile & ".txt"
        Dim path As String = Application.ExecutablePath
        path = path.ToLower().Replace("tcsclearing.exe", "")

        Dim fout As New FileStream(path & "logs\" & outfile, FileMode.Append, FileAccess.Write)
        Dim sr As New StreamWriter(fout)

        sr.Write("<Message>" & vbCrLf & Date.Now.ToString & " " & data & vbCrLf & "</Message>" & vbCrLf)
        sr.Close()

        ' Console.WriteLine(Date.Now.ToString & " " & data)


    End Sub

End Class

